package proxy.wrappers;

import android.os.IInterface;
import com.genymobile.scrcpy.Ln;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/* loaded from: classes2.dex */
public class StatusBarManager {
    private Method collapsePanelsMethod;
    private boolean expandNotificationPanelMethodCustomVersion;
    private Method expandNotificationsPanelMethod;
    private Method expandSettingsPanelMethod;
    private boolean expandSettingsPanelMethodNewVersion = true;
    private final IInterface manager;

    public StatusBarManager(IInterface manager) {
        this.manager = manager;
    }

    private Method getExpandNotificationsPanelMethod() throws NoSuchMethodException {
        if (this.expandNotificationsPanelMethod == null) {
            try {
                this.expandNotificationsPanelMethod = this.manager.getClass().getMethod("expandNotificationsPanel", new Class[0]);
            } catch (NoSuchMethodException e) {
                this.expandNotificationsPanelMethod = this.manager.getClass().getMethod("expandNotificationsPanel", Integer.TYPE);
                this.expandNotificationPanelMethodCustomVersion = true;
            }
        }
        return this.expandNotificationsPanelMethod;
    }

    private Method getExpandSettingsPanel() throws NoSuchMethodException {
        if (this.expandSettingsPanelMethod == null) {
            try {
                this.expandSettingsPanelMethod = this.manager.getClass().getMethod("expandSettingsPanel", String.class);
            } catch (NoSuchMethodException e) {
                this.expandSettingsPanelMethod = this.manager.getClass().getMethod("expandSettingsPanel", new Class[0]);
                this.expandSettingsPanelMethodNewVersion = false;
            }
        }
        return this.expandSettingsPanelMethod;
    }

    private Method getCollapsePanelsMethod() throws NoSuchMethodException {
        if (this.collapsePanelsMethod == null) {
            this.collapsePanelsMethod = this.manager.getClass().getMethod("collapsePanels", new Class[0]);
        }
        return this.collapsePanelsMethod;
    }

    public void expandNotificationsPanel() {
        try {
            Method method = getExpandNotificationsPanelMethod();
            if (this.expandNotificationPanelMethodCustomVersion) {
                method.invoke(this.manager, 0);
            } else {
                method.invoke(this.manager, new Object[0]);
            }
        } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
            Ln.e("Could not invoke method", e);
        }
    }

//    public void expandSettingsPanel() {
//        try {
//            Method method = getExpandSettingsPanel();
//            if (this.expandSettingsPanelMethodNewVersion) {
//                method.invoke(this.manager, null);
//            } else {
//                method.invoke(this.manager, new Object[0]);
//            }
//        } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
//            Ln.e("Could not invoke method", e);
//        }
//    }

    public void collapsePanels() {
        try {
            Method method = getCollapsePanelsMethod();
            method.invoke(this.manager, new Object[0]);
        } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
            Ln.e("Could not invoke method", e);
        }
    }
}